<template>
  <transition name="fade">
    <div class="mask-box" v-if="show">
      <div class="hap-modal">
        <div class="hap-modal-title">{{option.desc}}</div>
        <div v-if="option.input" class="hap-modal-input"><input type="text" :placeholder="placeHolder" v-model="option.content"/></div>
        <div class="hap-modal-btn-group">
          <div class="hap-btn-confirm hap-btn" @click="clickConfirm">确定</div>
          <div class="hap-btn-cancle hap-btn" @click="clickCancle">取消</div>
        </div>
      </div>
    </div>
  </transition>
</template>
<script>
export default {
  data () {
    return {
      placeHolder: '请输入文件名称'
    }
  },
  props: ['show', 'option'],
  methods: {
    clickConfirm () {
      this.$emit('confirm', this.option.content)
    },
    clickCancle () {
      this.$emit('cancel')
    }
  }
}
</script>
<style lang="less" scoped>
.hap-modal {
  text-align: center;
  border-radius: 5px;
}
.hap-modal-input {
  margin-top: 20px;
  height: 32px;
  input {
    height: 100%;
    width: 150px;
    padding: 0 10px;
    box-sizing: border-box;
  }
}
.hap-modal-title {
  margin-top: 30px;
}
.fade-enter-active, .fade-leave-active {
  transition: opacity .3s ease;
}
.fade-leave {
  opacity: 0;
}
.mask-box {
  position: fixed;
  z-index: 1000;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
}
.hap-modal {
  overflow: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #FFF;
  width: 300px;
}
.hap-modal-btn-group {
  margin-top: 20px;
  margin-bottom: 30px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.hap-btn {
  box-sizing: border-box;
  cursor: pointer;
  height: 32px;
  line-height: 32px;
  padding: 0 20px;
  margin: 0 10px;
  font-size: 16px;
  border-radius: 5px;
  border: 1px solid #666;
  &:hover {
    background: #09d2f9;
    color: #FFF;
    border: 1px solid #09d2f9;
  }
}
</style>
